package com.slz3.business.module.goodsManagement.gooGoods.steward;

import com.slz3.business.frame.response.RR;
import com.slz3.business.frame.response.ResInfo;
import com.slz3.business.module.goodsManagement.gooGoods.domain.GooGoods;
import com.slz3.business.module.goodsManagement.gooGoods.domain.GooGoodsCondition;
import org.springframework.stereotype.Controller;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;

@Controller
public class GooGoodsResController {

    @Resource
    private GooGoodsResAtomic gooGoodsResAtomic;

    public Mono<ServerResponse> add(ServerRequest req, GooGoods gooGoods) {
        if (GooGoodsResUnsafeValid.add(req, gooGoods)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooGoodsResAtomic.add_$GooGoodsUpdateLock(req, gooGoods);
        }
    }

    public  Mono<ServerResponse> delete(ServerRequest req, GooGoodsCondition gooGoodsCondition) {
        if (GooGoodsResUnsafeValid.delete(req, gooGoodsCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooGoodsResAtomic.delete_$GooGoodsUpdateLock(req, gooGoodsCondition);
        }
    }

    public Mono<ServerResponse> modify(ServerRequest req, GooGoods gooGoods) {
        if (GooGoodsResUnsafeValid.modify(req, gooGoods)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooGoodsResAtomic.modify_$GooGoodsUpdateLock(req, gooGoods);
        }
    }

    public Mono<ServerResponse> list(ServerRequest req) {
        if (GooGoodsResUnsafeValid.list(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return GooGoodsResExecutor.list(req);
        }
    }

    public Mono<ServerResponse> info(ServerRequest req) {
        if (GooGoodsResUnsafeValid.info(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooGoodsResAtomic.info_$GooGoodsUpdateLock(req);
        }
    }

    public Mono<ServerResponse> choice(ServerRequest req) {
        if (GooGoodsResUnsafeValid.choice(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return GooGoodsResExecutor.choice(req);
        }
    }

    public final Mono<ServerResponse> auditSubmit(ServerRequest req, GooGoodsCondition gooGoodsCondition) {
        //
        if (GooGoodsResUnsafeValid.auditSubmit(req, gooGoodsCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooGoodsResAtomic.auditSubmit_$GooGoodsUpdateLock(req, gooGoodsCondition);
        }
    }

    public final Mono<ServerResponse> audit(ServerRequest req, GooGoodsCondition gooGoodsCondition) {
        if (GooGoodsResUnsafeValid.audit(req, gooGoodsCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooGoodsResAtomic.audit_$GooGoodsUpdateLock(req, gooGoodsCondition);
        }
    }

    public final Mono<ServerResponse> auditReject(ServerRequest req, GooGoodsCondition gooGoodsCondition) {
        if (GooGoodsResUnsafeValid.auditReject(req, gooGoodsCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooGoodsResAtomic.auditReject_$GooGoodsUpdateLock(req, gooGoodsCondition);
        }
    }

    public final Mono<ServerResponse> usingEnable(ServerRequest req, GooGoodsCondition gooGoodsCondition) {
        if (GooGoodsResUnsafeValid.usingEnable(req, gooGoodsCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooGoodsResAtomic.usingEnable_$GooGoodsUpdateLock(req, gooGoodsCondition);
        }
    }

    public final Mono<ServerResponse> usingDisable(ServerRequest req, GooGoodsCondition gooGoodsCondition) {
        if (GooGoodsResUnsafeValid.usingDisable(req, gooGoodsCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooGoodsResAtomic.usingDisable_$GooGoodsUpdateLock(req, gooGoodsCondition);
        }
    }

}
